package com.itheima.Dao;

import com.itheima.bean.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper   //ibatis 提供,当Spring扫描到这个包之后,会给这个接口生成对应的实体类对象(动态代理
public interface BookDao {
    //根据id 查询书籍信息
    @Select("select * from book where id=#{id}")
    public Book getById(Integer id);
    //查询所有书籍信息
    @Select("select * from book")
    public List<Book> getAll();

    // 添加书籍信息
    @Insert("insert into book (type,name,description) values(#{type},#{name},#{description})")
    int save(Book book);

    //删除书籍信息
    @Delete("delete from book where id=#{id}")
    int delete(Integer id);

    @Update("update book set type=#{type},name=#{name},description=#{description} where id=#{id}")
    int update(Book book);
}
